import os

"""
This is the example of comments
"""

print(os.getcwd())
try:
    with open('./ch0304/sketch.txt') as data_in , \
                open('./ch0304/man.txt','w') as data_man , \
                    open('./ch0304/otherman.txt','w') as data_otherman , \
                        open('./ch0304/other.txt','w') as data_other: 
        for each_line in data_in:
            try:
                (role, saying) = each_line.split(':',1)
                role = role.strip().upper()                                    
                if (role == "MAN"):
                    print(saying, file = data_man, end = '')                    
                elif (role == "OTHER MAN"):
                    print(saying, file = data_otherman, end = '')
                else:
                    print("not role:", role, "-->", saying) 
                    print(each_line, file = data_other, end = '')  
            except ValueError as ex:
                print("pass error, skip:", ex)           
except IOError as ex:
    print(ex)


